package cn.iotab.iotkit.server.demo.device.handler.firmware;

import cn.iotab.iotkit.transport.api.access.device.listener.firmware.DeviceReportUpgradeProgressListener;
import cn.iotab.iotkit.transport.api.access.model.custom.firmware.ReportUpgradeProgressMessage;
import cn.iotab.iotkit.transport.api.access.model.message.DeviceMessageReply;
import cn.iotab.iotkit.transport.api.common.util.JsonUtil;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * <pre>
 *  {
 *     "id":"123",
 *     "ver":"1.0",
 *     "ack":0,
 *     "type":"firmware.progress",
 *     "param":{
 *         "progress":80,
 *         "complete":false,
 *         "version":"1.2.3",
 *         "success":true,
 *         "errorReason":null,
 *         "firmwareId":"122124"
 *     }
 * }
 * </pre>
 */
@Slf4j
@Component
public class MyDeviceReportUpgradeProgressListener extends DeviceReportUpgradeProgressListener {
    @Override
    protected ListenableFuture<DeviceMessageReply> doProcess(ReportUpgradeProgressMessage message) {
        log.info("收到设备上报升级进度：{}", JsonUtil.toJsonString(message));
        return null;
    }
}
